package org.apache.lucene.distributed;

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.Serializable;

import org.apache.lucene.distributed.RMI.ProxyKey;

/**
 * Each RMI.Server has a canonical NameService that gives
 * access to and information about the objects offered by the server
 *
 */
public interface NameService {
  public int getNumRefs(String service) throws Exception;
  public String[] getNames() throws Exception;
  /**
   * 
   * @param lease
   * @return lease id
   * @throws Exception
   */
  public String renew(Lease lease) throws Exception;
  
  /**
   * Creates refs to a service for use with distributed garbage collection
   */
  public static class Lease implements Serializable {
    public String id;
    public String service;
    public long duration;
    
    public Lease(String id, String service, long duration) {
      this.id = id;
      this.service = service;
      this.duration = duration;
    }
    
    
  }
}
